
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui-v2.4.5/layui/css/layui.css" media="all">
    <script src="../../layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<form class="layui-form" action="">
    <input name="id" value="${record.id}" type="hidden">



    <div class="layui-form-item">
        <label class="layui-form-label">商户名</label>
        <div class="layui-input-block">
            <input type="text" name="merchant_name" required  lay-verify="required"
                   placeholder="请输入商户名" autocomplete="off" class="layui-input" value="${record.merchant_name}">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" name="phone" required  lay-verify="required"
                   placeholder="请输入电话" autocomplete="off" class="layui-input" value="${record.phone}">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input type="text" name="adress" required  lay-verify="required"
                   placeholder="请输入地址" autocomplete="off" class="layui-input" value="${record.adress}">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">每单提成</label>
        <div class="layui-input-block">
            <input type="text" name="per_commission" required  lay-verify="required"
                   placeholder="请输入每单提成" autocomplete="off" class="layui-input" value="${record.per_commission}">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">收费类型</label>
        <div class="layui-input-block">
            <select name="charges_type" lay-filter="aihao">
                <option value="${record.charges_type}"></option>
                <option value="按年">按年</option>
                <option value="按月">按月</option>
                <option value="按季度">按季度</option>
            </select>
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">到期时间</label>
        <div class="layui-input-block">
            <input type="text" name="endTime" required  lay-verify="required"
                   placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" value="${record.endTime}">
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <%--<button type="reset" class="layui-btn layui-btn-primary">重置</button>--%>
        </div>
    </div>


</form>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form

        //监听提交
        form.on('submit(formDemo)', function(data){
            //layer.msg(JSON.stringify(data.field));
            console.log(data)
            $.ajax({
                url:'/shop/updaShop',
                type:'POST', //GET
                async:true,    //或false,是否异步
                data:data.field,
                timeout:5000,    //超时时间
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend:function(xhr){
                    /*console.log(xhr)
                     console.log('发送前')*/
                },
                success:function(data){
                    console.log(data);
                    if (data.code=='000000'){
                        layer.msg(data.msg,{time:1000,icon: 6},function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        });
                        // 获得frame索引
                    }else {
                        layer.msg(data.msg,{time:1000,icon: 5});
                    }
                    //console.log(data)
                },
                error:function(xhr,textStatus){
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                },
                complete:function() {
                    //console.log('结束')
                }
            });
            return false;
        });
    });
</script>
</body>
</html>